// Copyright (C) Kumo inc. and its affiliates.
// Author: Jeff.li lijippy@163.com
// All rights reserved.
// This program is free software: you can redistribute it and/or modify
// it under the terms of the GNU Affero General Public License as published
// by the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
// GNU Affero General Public License for more details.
//
// You should have received a copy of the GNU Affero General Public License
// along with this program.  If not, see <https://www.gnu.org/licenses/>.
//


#include <string>
#include <pollux/functions/registerer.h>
#include <pollux/functions/prestosql/bing_tile_functions.h>
#include <pollux/functions/prestosql/types/bing_tile_registration.h>
#include <pollux/functions/prestosql/types/bing_tile_type.h>
#include <pollux/functions/prestosql/types/geometry_registration.h>
#include <pollux/type/simple_function_api.h>

namespace kumo::pollux::functions {
    namespace {
        void registerSimpleBingTileFunctions(const std::string &prefix) {
            // BingTile constructors
            register_function<BingTileFunction, BingTile, int32_t, int32_t, int8_t>(
                {prefix + "bing_tile"});
            register_function<BingTileFunction, BingTile, Varchar>({prefix + "bing_tile"});

            // BingTile accessors
            register_function<BingTileZoomLevelFunction, int8_t, BingTile>(
                {prefix + "bing_tile_zoom_level"});
            register_function<
                BingTileCoordinatesFunction,
                Row<int32_t, int32_t>,
                BingTile>({prefix + "bing_tile_coordinates"});

            // Parent/child tiles
            register_function<BingTileParentFunction, BingTile, BingTile>(
                {prefix + "bing_tile_parent"});
            register_function<BingTileParentFunction, BingTile, BingTile, int8_t>(
                {prefix + "bing_tile_parent"});
            register_function<BingTileChildrenFunction, Array<BingTile>, BingTile>(
                {prefix + "bing_tile_children"});
            register_function<BingTileChildrenFunction, Array<BingTile>, BingTile, int8_t>(
                {prefix + "bing_tile_children"});
            register_function<BingTileToQuadKeyFunction, Varchar, BingTile>(
                {prefix + "bing_tile_quadkey"});
        }
    } // namespace

    void registerBingTileFunctions(const std::string &prefix) {
        registerBingTileType();

        // TODO: Remove this once we have GeometryFunctionsRegistration
        registerGeometryType();

        registerSimpleBingTileFunctions(prefix);
    }
} // namespace kumo::pollux::functions
